package com.netease.financial.module.activitypage;

import com.netease.financial.common.constant.Constants;
import com.netease.financial.common.util.preferences.PreferencesHelper;

/**
 * Created by wyf on 10/10/15.
 */
public class AdvertisementPreferencesHelper {

    private static final String PREFERENCES_FILE_NAME = PreferencesHelper.getFullPreferenceFileName("advertisement");

    private static final String KEY_ACTIVITY_PAGE_ICON_URL = "activity_page_icon_url";
    private static final String KEY_ACTIVITY_PAGE_TITLE = "activity_page_title";
    private static final String KEY_ACTIVITY_PAGE_URL = "activity_page_url";
    private static final String KEY_LAUNCH_PAGE_IMAGE_URL = "launch_page_image_url";
    private static final String KEY_LAUNCH_PAGE = "launch_page";

    private static PreferencesHelper sPreferencesHelper;

    private static PreferencesHelper getPreferencesHelper() {
        if (sPreferencesHelper == null) {
            sPreferencesHelper = PreferencesHelper.newInstance(PREFERENCES_FILE_NAME);
        }
        return sPreferencesHelper;
    }

    public static String getActivityIconUrl() {
        return getPreferencesHelper().getString(KEY_ACTIVITY_PAGE_ICON_URL, Constants.DOMAIN_BODY);
    }

    public static void setActivityIconUrl(String iconUrl) {
        getPreferencesHelper().putString(KEY_ACTIVITY_PAGE_ICON_URL, iconUrl);
    }

    public static String getActivityPageTitle() {
        return getPreferencesHelper().getString(KEY_ACTIVITY_PAGE_TITLE, "");
    }

    public static void setActivityPageTitle(String title) {
        getPreferencesHelper().putString(KEY_ACTIVITY_PAGE_TITLE, title);
    }

    public static String getActivityPageUrl() {
        return getPreferencesHelper().getString(KEY_ACTIVITY_PAGE_URL, "");
    }

    public static void setActivityPageUrl(String pageUrl) {
        getPreferencesHelper().putString(KEY_ACTIVITY_PAGE_URL, pageUrl);
    }

    public static String getLaunchPage() {
        return getPreferencesHelper().getString(KEY_LAUNCH_PAGE, "");
    }

    public static void setLaunchPage(String launchPage) {
        getPreferencesHelper().putString(KEY_LAUNCH_PAGE, launchPage);
    }

}
